﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace demo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new ValidationFormViewModel();
        }


        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            ResetSubmitButton();
        }

        private void ResetSubmitButton()
        {
            var b1 = Validation.GetHasError(nameTextBox);
            //var b2 = Validation.GetHasError(ageTextBox);
            //var b3 = Validation.GetHasError(remarkTextBox);

            submitButton.IsEnabled = !b1;//&& !b2 && !b3;
        }

        private void submitButton_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("提交");
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            ResetSubmitButton();
        }

    }
}
